<template>
	<view class="container">
		<loading-page mode="fullScreen" :show="initLoading"></loading-page>
		<view class="main" v-if="!initLoading">
			<m-start-ad :list="systemConfig.open_ad_imgs || []" url="/pages/index/index" :time="time"
				@swiperChange="swiperChange" />
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	import mStartAd from './components/m-start-ad.vue'
	export default {
		components: {
			mStartAd
		},
		data() {
			return {}

		},
		computed: {
			...mapState({
				initLoading: (state) => state.init.initLoading,
				systemConfig: (state) => state.init.systemConfig
			}),
			time() {
				if (this.systemConfig && this.systemConfig.open_ad_time) {
					return Number(this.systemConfig.open_ad_time)
				}
				return 0
			}
		},
		methods: {
			swiperChange() {
				if (this.systemConfig.open_ad_jump_url) {
					const urlParts = this.systemConfig.open_ad_jump_url.split('/');
					const isSubPackagesPath = urlParts[1] === 'subPackages';
					if (isSubPackagesPath) {
						this.$reLaunch(this.systemConfig.open_ad_jump_url);
					} else {
						this.$switchTab(this.systemConfig.open_ad_jump_url);
					}
				}
			},
		}
	}
</script>

<style>
</style>